package com.huajin;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.huajin.codetest.context.ServerContext;
import com.huajin.codetest.mail.MailConfig;
import com.huajin.codetest.mail.MailConfigTest;

@SpringBootApplication
public class Application {
	
	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
		MailConfigTest test = ServerContext.getBean(MailConfigTest.class);
		test.autoMailConfig("snms", "host1", "username1", "password1");
		test.autoMailConfig("cwrr", "host2", "username2", "password2");
		MailConfig snmsMailConfig = ServerContext.getBean("snmsMailConfig", MailConfig.class);
		MailConfig cwrrMailConfig = ServerContext.getBean("cwrrMailConfig", MailConfig.class);
		try {
			System.out.println("====snmsMailConfig===" + new ObjectMapper().writeValueAsString(snmsMailConfig));
			System.out.println("====cwrrMailConfig===" + new ObjectMapper().writeValueAsString(cwrrMailConfig));
		} catch (JsonProcessingException e) {
			e.printStackTrace();
		}
	}
    
}